// pages/home/home.js
const app = getApp();
import { createDrawBoard } from '../../api/api';
import { getUserInfo, linkToDraw } from '../../utils/utils'

Page({
  beginDrawBtn: async function (e) {
    getUserInfo().then(
      userInfo => {
        this.createBoard(userInfo)
      }
    )
  },
  createBoard: async function (userInfo) {
    wx.showLoading({
      title: '创建画板中～',
    })
    const { drawBoardId } = await createDrawBoard(userInfo);
    wx.hideLoading();
    linkToDraw(drawBoardId);
  }
})